{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Output Methods"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "The most common for interactive usage are:\n",
    "output_file\n",
    "    For generating simple standalone HTML documents for Bokeh visualizations.\n",
    "output_notebook\n",
    "    For displaying Bokeh visualizations inline in Jupyter/Zeppelin notebook cells."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## output_file(输出至文件)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from bokeh.plotting import figure, output_file,show\n",
    "\n",
    "#输出方式为html文件\n",
    "output_file(\"Output//3_1-Output.html\")\n",
    "#生成空的图表框\n",
    "p=figure()\n",
    "p.line(x=[1,2,3],y=[4,6,2])\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## output_notebook(输出到notebook-屏幕)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"https://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"9e0f4b1a-0d42-4180-918e-fd25b0913155\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(root) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "    root._bokeh_onload_callbacks = [];\n",
       "    root._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "\n",
       "  \n",
       "  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    root._bokeh_timeout = Date.now() + 5000;\n",
       "    root._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    if (root.Bokeh !== undefined) {\n",
       "      var el = document.getElementById(\"9e0f4b1a-0d42-4180-918e-fd25b0913155\");\n",
       "      if (el != null) {\n",
       "        el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "      }\n",
       "    } else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "\n",
       "  function run_callbacks() {\n",
       "    try {\n",
       "      root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "    }\n",
       "    finally {\n",
       "      delete root._bokeh_onload_callbacks\n",
       "    }\n",
       "    console.info(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(js_urls, callback) {\n",
       "    root._bokeh_onload_callbacks.push(callback);\n",
       "    if (root._bokeh_is_loading > 0) {\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    root._bokeh_is_loading = js_urls.length;\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var s = document.createElement('script');\n",
       "      s.src = url;\n",
       "      s.async = false;\n",
       "      s.onreadystatechange = s.onload = function() {\n",
       "        root._bokeh_is_loading--;\n",
       "        if (root._bokeh_is_loading === 0) {\n",
       "          console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "          run_callbacks()\n",
       "        }\n",
       "      };\n",
       "      s.onerror = function() {\n",
       "        console.warn(\"failed to load library \" + url);\n",
       "      };\n",
       "      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "  };var element = document.getElementById(\"9e0f4b1a-0d42-4180-918e-fd25b0913155\");\n",
       "  if (element == null) {\n",
       "    console.log(\"Bokeh: ERROR: autoload.js configured with elementid '9e0f4b1a-0d42-4180-918e-fd25b0913155' but no matching script tag was found. \")\n",
       "    return false;\n",
       "  }\n",
       "\n",
       "  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.7.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.7.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.7.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.7.min.js\"];\n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "      document.getElementById(\"9e0f4b1a-0d42-4180-918e-fd25b0913155\").textContent = \"BokehJS is loading...\";\n",
       "    },\n",
       "    function(Bokeh) {\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.7.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.7.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.7.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.7.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.7.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.7.min.css\");\n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "      for (var i = 0; i < inline_js.length; i++) {\n",
       "        inline_js[i].call(root, root.Bokeh);\n",
       "      }if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!root._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      root._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"9e0f4b1a-0d42-4180-918e-fd25b0913155\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (root._bokeh_is_loading === 0) {\n",
       "    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(js_urls, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(window));"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <div class=\"bk-plotdiv\" id=\"457489ad-7c2d-40a2-bd3b-ff3c11914ae7\"></div>\n",
       "    </div>\n",
       "<script type=\"text/javascript\">\n",
       "  \n",
       "  (function(root) {\n",
       "    function now() {\n",
       "      return new Date();\n",
       "    }\n",
       "  \n",
       "    var force = false;\n",
       "  \n",
       "    if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "      root._bokeh_onload_callbacks = [];\n",
       "      root._bokeh_is_loading = undefined;\n",
       "    }\n",
       "  \n",
       "  \n",
       "    \n",
       "    if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "      root._bokeh_timeout = Date.now() + 0;\n",
       "      root._bokeh_failed_load = false;\n",
       "    }\n",
       "  \n",
       "    var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "       \"<div style='background-color: #fdd'>\\n\"+\n",
       "       \"<p>\\n\"+\n",
       "       \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "       \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "       \"</p>\\n\"+\n",
       "       \"<ul>\\n\"+\n",
       "       \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "       \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "       \"</ul>\\n\"+\n",
       "       \"<code>\\n\"+\n",
       "       \"from bokeh.resources import INLINE\\n\"+\n",
       "       \"output_notebook(resources=INLINE)\\n\"+\n",
       "       \"</code>\\n\"+\n",
       "       \"</div>\"}};\n",
       "  \n",
       "    function display_loaded() {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        var el = document.getElementById(\"457489ad-7c2d-40a2-bd3b-ff3c11914ae7\");\n",
       "        if (el != null) {\n",
       "          el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "        }\n",
       "      } else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(display_loaded, 100)\n",
       "      }\n",
       "    }\n",
       "  \n",
       "  \n",
       "    function run_callbacks() {\n",
       "      try {\n",
       "        root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "      }\n",
       "      finally {\n",
       "        delete root._bokeh_onload_callbacks\n",
       "      }\n",
       "      console.info(\"Bokeh: all callbacks have finished\");\n",
       "    }\n",
       "  \n",
       "    function load_libs(js_urls, callback) {\n",
       "      root._bokeh_onload_callbacks.push(callback);\n",
       "      if (root._bokeh_is_loading > 0) {\n",
       "        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "        return null;\n",
       "      }\n",
       "      if (js_urls == null || js_urls.length === 0) {\n",
       "        run_callbacks();\n",
       "        return null;\n",
       "      }\n",
       "      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "      root._bokeh_is_loading = js_urls.length;\n",
       "      for (var i = 0; i < js_urls.length; i++) {\n",
       "        var url = js_urls[i];\n",
       "        var s = document.createElement('script');\n",
       "        s.src = url;\n",
       "        s.async = false;\n",
       "        s.onreadystatechange = s.onload = function() {\n",
       "          root._bokeh_is_loading--;\n",
       "          if (root._bokeh_is_loading === 0) {\n",
       "            console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "            run_callbacks()\n",
       "          }\n",
       "        };\n",
       "        s.onerror = function() {\n",
       "          console.warn(\"failed to load library \" + url);\n",
       "        };\n",
       "        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      }\n",
       "    };var element = document.getElementById(\"457489ad-7c2d-40a2-bd3b-ff3c11914ae7\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid '457489ad-7c2d-40a2-bd3b-ff3c11914ae7' but no matching script tag was found. \")\n",
       "      return false;\n",
       "    }\n",
       "  \n",
       "    var js_urls = [];\n",
       "  \n",
       "    var inline_js = [\n",
       "      function(Bokeh) {\n",
       "        (function() {\n",
       "          var fn = function() {\n",
       "            var docs_json = {\"05b38897-9f37-4a44-8e36-01c74eedb91c\":{\"roots\":{\"references\":[{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"f9f2d60b-c2fa-485f-b59e-900c5fd9ebc3\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"2c0e23be-61bc-4799-bb6b-4677bab58856\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1,2,3],\"y\":[4,6,2]}},\"id\":\"0c07c992-d416-427a-b4f8-b55676b5e0f0\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"plot\":{\"id\":\"3ad2387c-9d96-493d-bfbb-46d95c3377cc\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2e1b8a71-f31f-4b39-9b32-70643de26e1a\",\"type\":\"BasicTicker\"}},\"id\":\"5f4903a2-590e-4e69-ba98-96ae4167dcf8\",\"type\":\"Grid\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"422860ee-6928-408f-9336-30bad40576cd\",\"type\":\"PanTool\"},{\"id\":\"078fdf9c-93c7-46f7-92df-94eaaba34a88\",\"type\":\"WheelZoomTool\"},{\"id\":\"0829be53-0f7f-4200-a708-e31efc3e043c\",\"type\":\"BoxZoomTool\"},{\"id\":\"96738951-b243-4bd4-a3e6-10b67eff1881\",\"type\":\"SaveTool\"},{\"id\":\"ff981aac-4f13-4115-8ba1-a02fb036c3f9\",\"type\":\"ResetTool\"},{\"id\":\"db2b358d-d647-480f-a9ab-7ee8b530d4d5\",\"type\":\"HelpTool\"}]},\"id\":\"a4b4ef0f-bc69-4bdc-9b65-db58473924b2\",\"type\":\"Toolbar\"},{\"attributes\":{\"formatter\":{\"id\":\"e72ce18c-b327-431e-9189-ce0c2562d954\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"3ad2387c-9d96-493d-bfbb-46d95c3377cc\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"8c4ca757-2ef4-4499-9980-a78d657fdb19\",\"type\":\"BasicTicker\"}},\"id\":\"77acc69f-383e-4479-8076-1a3446446367\",\"type\":\"LinearAxis\"},{\"attributes\":{\"overlay\":{\"id\":\"99b0d2cb-b15a-459a-9b00-d58a0544d955\",\"type\":\"BoxAnnotation\"}},\"id\":\"0829be53-0f7f-4200-a708-e31efc3e043c\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"formatter\":{\"id\":\"fcca3d28-be86-4f04-9fda-ea316e3a5aae\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"3ad2387c-9d96-493d-bfbb-46d95c3377cc\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2e1b8a71-f31f-4b39-9b32-70643de26e1a\",\"type\":\"BasicTicker\"}},\"id\":\"640df563-277d-49af-aca2-893e83a3754b\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null},\"id\":\"9684b23c-a905-415e-a512-3dc0bc222723\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"db2b358d-d647-480f-a9ab-7ee8b530d4d5\",\"type\":\"HelpTool\"},{\"attributes\":{\"below\":[{\"id\":\"640df563-277d-49af-aca2-893e83a3754b\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"77acc69f-383e-4479-8076-1a3446446367\",\"type\":\"LinearAxis\"}],\"plot_height\":250,\"plot_width\":250,\"renderers\":[{\"id\":\"640df563-277d-49af-aca2-893e83a3754b\",\"type\":\"LinearAxis\"},{\"id\":\"5f4903a2-590e-4e69-ba98-96ae4167dcf8\",\"type\":\"Grid\"},{\"id\":\"77acc69f-383e-4479-8076-1a3446446367\",\"type\":\"LinearAxis\"},{\"id\":\"92207e33-2944-4919-a26b-357c9f06a5f9\",\"type\":\"Grid\"},{\"id\":\"99b0d2cb-b15a-459a-9b00-d58a0544d955\",\"type\":\"BoxAnnotation\"},{\"id\":\"758fc4eb-2585-44db-91b6-b4b1b7224329\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"86caebe9-d275-4f4d-a249-6e0490a55c76\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"a4b4ef0f-bc69-4bdc-9b65-db58473924b2\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"9684b23c-a905-415e-a512-3dc0bc222723\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"7f22e156-e6dd-4de7-84a1-fc607a83a54a\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"4dfb27ef-3fcb-4740-8c66-7ccc06add36d\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"2c0e23be-61bc-4799-bb6b-4677bab58856\",\"type\":\"LinearScale\"}},\"id\":\"3ad2387c-9d96-493d-bfbb-46d95c3377cc\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"fcca3d28-be86-4f04-9fda-ea316e3a5aae\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"data_source\":{\"id\":\"0c07c992-d416-427a-b4f8-b55676b5e0f0\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"decb3fed-3223-4b54-92d6-7762c6c70044\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"f9f2d60b-c2fa-485f-b59e-900c5fd9ebc3\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"c589c5e8-3598-460a-be41-2d7b4ca6752c\",\"type\":\"CDSView\"}},\"id\":\"758fc4eb-2585-44db-91b6-b4b1b7224329\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"0c07c992-d416-427a-b4f8-b55676b5e0f0\",\"type\":\"ColumnDataSource\"}},\"id\":\"c589c5e8-3598-460a-be41-2d7b4ca6752c\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"2e1b8a71-f31f-4b39-9b32-70643de26e1a\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"078fdf9c-93c7-46f7-92df-94eaaba34a88\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"422860ee-6928-408f-9336-30bad40576cd\",\"type\":\"PanTool\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"99b0d2cb-b15a-459a-9b00-d58a0544d955\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"96738951-b243-4bd4-a3e6-10b67eff1881\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"8c4ca757-2ef4-4499-9980-a78d657fdb19\",\"type\":\"BasicTicker\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"86caebe9-d275-4f4d-a249-6e0490a55c76\",\"type\":\"Title\"},{\"attributes\":{\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"decb3fed-3223-4b54-92d6-7762c6c70044\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null},\"id\":\"4dfb27ef-3fcb-4740-8c66-7ccc06add36d\",\"type\":\"DataRange1d\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"3ad2387c-9d96-493d-bfbb-46d95c3377cc\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"8c4ca757-2ef4-4499-9980-a78d657fdb19\",\"type\":\"BasicTicker\"}},\"id\":\"92207e33-2944-4919-a26b-357c9f06a5f9\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"ff981aac-4f13-4115-8ba1-a02fb036c3f9\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"e72ce18c-b327-431e-9189-ce0c2562d954\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"7f22e156-e6dd-4de7-84a1-fc607a83a54a\",\"type\":\"LinearScale\"}],\"root_ids\":[\"3ad2387c-9d96-493d-bfbb-46d95c3377cc\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.7\"}};\n",
       "            var render_items = [{\"docid\":\"05b38897-9f37-4a44-8e36-01c74eedb91c\",\"elementid\":\"457489ad-7c2d-40a2-bd3b-ff3c11914ae7\",\"modelid\":\"3ad2387c-9d96-493d-bfbb-46d95c3377cc\"}];\n",
       "            \n",
       "            Bokeh.embed.embed_items(docs_json, render_items);\n",
       "          };\n",
       "          if (document.readyState != \"loading\") fn();\n",
       "          else document.addEventListener(\"DOMContentLoaded\", fn);\n",
       "        })();\n",
       "      },\n",
       "      function(Bokeh) {\n",
       "      }\n",
       "    ];\n",
       "  \n",
       "    function run_inline_js() {\n",
       "      \n",
       "      if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "        for (var i = 0; i < inline_js.length; i++) {\n",
       "          inline_js[i].call(root, root.Bokeh);\n",
       "        }if (force === true) {\n",
       "          display_loaded();\n",
       "        }} else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(run_inline_js, 100);\n",
       "      } else if (!root._bokeh_failed_load) {\n",
       "        console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "        root._bokeh_failed_load = true;\n",
       "      } else if (force !== true) {\n",
       "        var cell = $(document.getElementById(\"457489ad-7c2d-40a2-bd3b-ff3c11914ae7\")).parents('.cell').data().cell;\n",
       "        cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "      }\n",
       "  \n",
       "    }\n",
       "  \n",
       "    if (root._bokeh_is_loading === 0) {\n",
       "      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "      run_inline_js();\n",
       "    } else {\n",
       "      load_libs(js_urls, function() {\n",
       "        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "        run_inline_js();\n",
       "      });\n",
       "    }\n",
       "  }(window));\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.plotting import figure, output_notebook,show\n",
    "\n",
    "#输出方式为otebook-屏幕,不需要文件名\n",
    "output_notebook()\n",
    "#生成空的图表框\n",
    "p=figure(width=250,plot_height=250)\n",
    "p.line(x=[1,2,3],y=[4,6,2])\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Interfaces"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## bokeh.models (low-level)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# properties can be configured when a model object is initialized\n",
    "glyph = Rect(x=\"x\", y=\"y2\", w=10, h=20, line_color=None)\n",
    "\n",
    "# or by assigning values to attributes on the model later\n",
    "glyph.fill_alpha = 0.5\n",
    "glyph.fill_color = \"navy\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## bokeh.plotting (mid-level)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <div class=\"bk-plotdiv\" id=\"d55a5372-295d-4816-9f59-dd2e3cab2fcf\"></div>\n",
       "    </div>\n",
       "<script type=\"text/javascript\">\n",
       "  \n",
       "  (function(root) {\n",
       "    function now() {\n",
       "      return new Date();\n",
       "    }\n",
       "  \n",
       "    var force = false;\n",
       "  \n",
       "    if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "      root._bokeh_onload_callbacks = [];\n",
       "      root._bokeh_is_loading = undefined;\n",
       "    }\n",
       "  \n",
       "  \n",
       "    \n",
       "    if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "      root._bokeh_timeout = Date.now() + 0;\n",
       "      root._bokeh_failed_load = false;\n",
       "    }\n",
       "  \n",
       "    var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "       \"<div style='background-color: #fdd'>\\n\"+\n",
       "       \"<p>\\n\"+\n",
       "       \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "       \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "       \"</p>\\n\"+\n",
       "       \"<ul>\\n\"+\n",
       "       \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "       \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "       \"</ul>\\n\"+\n",
       "       \"<code>\\n\"+\n",
       "       \"from bokeh.resources import INLINE\\n\"+\n",
       "       \"output_notebook(resources=INLINE)\\n\"+\n",
       "       \"</code>\\n\"+\n",
       "       \"</div>\"}};\n",
       "  \n",
       "    function display_loaded() {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        var el = document.getElementById(\"d55a5372-295d-4816-9f59-dd2e3cab2fcf\");\n",
       "        if (el != null) {\n",
       "          el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "        }\n",
       "      } else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(display_loaded, 100)\n",
       "      }\n",
       "    }\n",
       "  \n",
       "  \n",
       "    function run_callbacks() {\n",
       "      try {\n",
       "        root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "      }\n",
       "      finally {\n",
       "        delete root._bokeh_onload_callbacks\n",
       "      }\n",
       "      console.info(\"Bokeh: all callbacks have finished\");\n",
       "    }\n",
       "  \n",
       "    function load_libs(js_urls, callback) {\n",
       "      root._bokeh_onload_callbacks.push(callback);\n",
       "      if (root._bokeh_is_loading > 0) {\n",
       "        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "        return null;\n",
       "      }\n",
       "      if (js_urls == null || js_urls.length === 0) {\n",
       "        run_callbacks();\n",
       "        return null;\n",
       "      }\n",
       "      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "      root._bokeh_is_loading = js_urls.length;\n",
       "      for (var i = 0; i < js_urls.length; i++) {\n",
       "        var url = js_urls[i];\n",
       "        var s = document.createElement('script');\n",
       "        s.src = url;\n",
       "        s.async = false;\n",
       "        s.onreadystatechange = s.onload = function() {\n",
       "          root._bokeh_is_loading--;\n",
       "          if (root._bokeh_is_loading === 0) {\n",
       "            console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "            run_callbacks()\n",
       "          }\n",
       "        };\n",
       "        s.onerror = function() {\n",
       "          console.warn(\"failed to load library \" + url);\n",
       "        };\n",
       "        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      }\n",
       "    };var element = document.getElementById(\"d55a5372-295d-4816-9f59-dd2e3cab2fcf\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'd55a5372-295d-4816-9f59-dd2e3cab2fcf' but no matching script tag was found. \")\n",
       "      return false;\n",
       "    }\n",
       "  \n",
       "    var js_urls = [];\n",
       "  \n",
       "    var inline_js = [\n",
       "      function(Bokeh) {\n",
       "        (function() {\n",
       "          var fn = function() {\n",
       "            var docs_json = {\"27d40080-954d-4c2d-8de9-8535d3b37526\":{\"roots\":{\"references\":[{\"attributes\":{\"callback\":null},\"id\":\"2a021929-b0bc-403c-b83e-2ae0bcc30ca0\",\"type\":\"DataRange1d\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"radius\":{\"units\":\"data\",\"value\":0.3},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"e78003f5-1544-43ad-97e8-22096e1a74ca\",\"type\":\"Circle\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1,2.5,3,2],\"y\":[2,3,1,1.5]}},\"id\":\"b34e8e07-5ff0-420b-b54b-7a76df9eaf8b\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"6391d531-88b0-4e01-8697-bc37b431cf3d\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"callback\":null},\"id\":\"3d316d36-3c67-4fbc-80d9-eb62f18941ad\",\"type\":\"DataRange1d\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"22549a06-2be3-4bb5-b322-68e13e9fb454\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"aaa7c892-986b-48b1-8cea-9c4730ddd600\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"ce4eb3cd-8015-4bf8-a09b-241e82d248cb\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"a46f04f7-95fe-4a83-b355-8b1f0a222fca\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"f1151dbe-d1d9-466b-9349-79d93cf4ae03\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"fea11032-9faf-46fb-b0fc-5f56f921bf14\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"fd81d3f7-95c7-432d-8dfc-69be7668c65c\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"087ae744-3383-43de-a8fd-75c980d6a4e7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"fea11032-9faf-46fb-b0fc-5f56f921bf14\",\"type\":\"BasicTicker\"}},\"id\":\"c3e39904-859d-4bad-8048-6a841b320ca1\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"6391d531-88b0-4e01-8697-bc37b431cf3d\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"087ae744-3383-43de-a8fd-75c980d6a4e7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"aaa7c892-986b-48b1-8cea-9c4730ddd600\",\"type\":\"BasicTicker\"}},\"id\":\"78c7488c-7206-44fa-ae36-a2df769e510e\",\"type\":\"LinearAxis\"},{\"attributes\":{\"below\":[{\"id\":\"78c7488c-7206-44fa-ae36-a2df769e510e\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"876f45fd-7655-4eee-99e1-a0583e91d5f3\",\"type\":\"LinearAxis\"}],\"plot_height\":300,\"plot_width\":300,\"renderers\":[{\"id\":\"78c7488c-7206-44fa-ae36-a2df769e510e\",\"type\":\"LinearAxis\"},{\"id\":\"3c0acf2d-2f94-4f45-b899-8b1ec9035ff6\",\"type\":\"Grid\"},{\"id\":\"876f45fd-7655-4eee-99e1-a0583e91d5f3\",\"type\":\"LinearAxis\"},{\"id\":\"c3e39904-859d-4bad-8048-6a841b320ca1\",\"type\":\"Grid\"},{\"id\":\"79e6e93c-ee29-4e72-88f2-4ee75fa7ef25\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"22549a06-2be3-4bb5-b322-68e13e9fb454\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"a756ad15-7a04-41d7-93d8-c5ee2920bd98\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"3d316d36-3c67-4fbc-80d9-eb62f18941ad\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"19ac9464-2235-43e5-99c2-85b3af358c70\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"2a021929-b0bc-403c-b83e-2ae0bcc30ca0\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"ce4eb3cd-8015-4bf8-a09b-241e82d248cb\",\"type\":\"LinearScale\"}},\"id\":\"087ae744-3383-43de-a8fd-75c980d6a4e7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"c2ecc5c6-27eb-4701-9eda-6ec18d8c721c\",\"type\":\"PanTool\"},{\"attributes\":{\"data_source\":{\"id\":\"b34e8e07-5ff0-420b-b54b-7a76df9eaf8b\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"5121eac6-ca11-44dc-a530-fb81f6bf16e5\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"e78003f5-1544-43ad-97e8-22096e1a74ca\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"76c978a6-94d8-4e22-b200-e34ab52c90dc\",\"type\":\"CDSView\"}},\"id\":\"79e6e93c-ee29-4e72-88f2-4ee75fa7ef25\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"c2ecc5c6-27eb-4701-9eda-6ec18d8c721c\",\"type\":\"PanTool\"},{\"id\":\"a46f04f7-95fe-4a83-b355-8b1f0a222fca\",\"type\":\"ResetTool\"},{\"id\":\"f1151dbe-d1d9-466b-9349-79d93cf4ae03\",\"type\":\"SaveTool\"}]},\"id\":\"a756ad15-7a04-41d7-93d8-c5ee2920bd98\",\"type\":\"Toolbar\"},{\"attributes\":{\"plot\":{\"id\":\"087ae744-3383-43de-a8fd-75c980d6a4e7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"aaa7c892-986b-48b1-8cea-9c4730ddd600\",\"type\":\"BasicTicker\"}},\"id\":\"3c0acf2d-2f94-4f45-b899-8b1ec9035ff6\",\"type\":\"Grid\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.5},\"line_color\":{\"value\":\"#1f77b4\"},\"radius\":{\"units\":\"data\",\"value\":0.3},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"5121eac6-ca11-44dc-a530-fb81f6bf16e5\",\"type\":\"Circle\"},{\"attributes\":{\"source\":{\"id\":\"b34e8e07-5ff0-420b-b54b-7a76df9eaf8b\",\"type\":\"ColumnDataSource\"}},\"id\":\"76c978a6-94d8-4e22-b200-e34ab52c90dc\",\"type\":\"CDSView\"},{\"attributes\":{\"formatter\":{\"id\":\"fd81d3f7-95c7-432d-8dfc-69be7668c65c\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"087ae744-3383-43de-a8fd-75c980d6a4e7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"fea11032-9faf-46fb-b0fc-5f56f921bf14\",\"type\":\"BasicTicker\"}},\"id\":\"876f45fd-7655-4eee-99e1-a0583e91d5f3\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"19ac9464-2235-43e5-99c2-85b3af358c70\",\"type\":\"LinearScale\"}],\"root_ids\":[\"087ae744-3383-43de-a8fd-75c980d6a4e7\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.7\"}};\n",
       "            var render_items = [{\"docid\":\"27d40080-954d-4c2d-8de9-8535d3b37526\",\"elementid\":\"d55a5372-295d-4816-9f59-dd2e3cab2fcf\",\"modelid\":\"087ae744-3383-43de-a8fd-75c980d6a4e7\"}];\n",
       "            \n",
       "            Bokeh.embed.embed_items(docs_json, render_items);\n",
       "          };\n",
       "          if (document.readyState != \"loading\") fn();\n",
       "          else document.addEventListener(\"DOMContentLoaded\", fn);\n",
       "        })();\n",
       "      },\n",
       "      function(Bokeh) {\n",
       "      }\n",
       "    ];\n",
       "  \n",
       "    function run_inline_js() {\n",
       "      \n",
       "      if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "        for (var i = 0; i < inline_js.length; i++) {\n",
       "          inline_js[i].call(root, root.Bokeh);\n",
       "        }if (force === true) {\n",
       "          display_loaded();\n",
       "        }} else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(run_inline_js, 100);\n",
       "      } else if (!root._bokeh_failed_load) {\n",
       "        console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "        root._bokeh_failed_load = true;\n",
       "      } else if (force !== true) {\n",
       "        var cell = $(document.getElementById(\"d55a5372-295d-4816-9f59-dd2e3cab2fcf\")).parents('.cell').data().cell;\n",
       "        cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "      }\n",
       "  \n",
       "    }\n",
       "  \n",
       "    if (root._bokeh_is_loading === 0) {\n",
       "      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "      run_inline_js();\n",
       "    } else {\n",
       "      load_libs(js_urls, function() {\n",
       "        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "        run_inline_js();\n",
       "      });\n",
       "    }\n",
       "  }(window));\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.plotting import figure,output_file,show\n",
    "\n",
    "#create a Figure object\n",
    "p=figure(plot_width=300,plot_height=300,tools=\"pan,reset,save\")\n",
    "\n",
    "#add a circle renderer to this figure\n",
    "p.circle(x=[1,2.5,3,2],y=[2,3,1,1.5],radius=0.3,alpha=0.5)\n",
    "\n",
    "#special how to outpu the plot(s)\n",
    "output_file(\"Output//3_2-foo.html\")\n",
    "\n",
    "#display figure\n",
    "show(p)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
